<table>
  <thead>
    <tr>
      <th>Group</th>
      <th>Students</th>
      <th>Goal</th>
      <th>Miles</th>
      <th>Last Updated</th>
      <th class="last"></th>
    </tr>
  </thead>
  <tbody>
    <% if @groups.blank? %>
      <td colspan="7" class="no_results">There are no groups added yet.</td>
    <% else %>
      <% @groups.each do |group| %>
        <tr class="<%= cycle('odd', 'even') %>">
          <%if self.current_user.can('view:group', group) %>
            <td><%= link_to h(group.name), group %></td>
          <%else%>
            <td><%= group.name %></td>
          <%end%>
          <td><%= group.runners_cache %></td>
          <td><%= group.goal_cache %></td>
          <td><%= group.distance_cache %></td>
	  <td><%= time_ago_in_words group.updated_at %> ago</td>
          <td class="last">
          <%if self.current_user.can('edit:group', group) %>
            <%= link_to(image_tag('icons/pencil.png', :alt => 'Edit'), edit_group_path(group)) %>
          <%end%>
          <%if self.current_user.can('delete:group', group) %>
            <%= link_to(image_tag('icons/cross.png', :alt => 'Delete'), group, :confirm => 'Are you sure?', :method => :delete) %>
          <%end%>
          </td>
          <td class="last">
            <%= render(:partial => "shared/progress_small", :locals => { :distance => group.distance_cache, :goal => group.goal_cache }) %>
          </td>

        </tr>
      <% end %>
    <% end %>
  </tbody>
</table> 

<%if self.current_user.can('create:group', @site) %>

<p>
<%= link_to 'Add new group', {:controller => "groups", :action => "new", :site_id => @site.id}%>
</p>
<%end%>